﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Sale.Api.Application.Command.ClientPrice;
using Sale.Dtos;
using Sale.ErrorCode;

namespace Sale.Api.Controllers
{
    /// <summary>
    /// 客户单价控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    //[Authorize]
    public class ClientPriceController : ControllerBase
    {
        private readonly IMediator mediator;

        public ClientPriceController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 客户单价添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> AddClientPrice(AddClientPriceCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 客户单价删除接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<int>> DelClientPrice([FromQuery]DelClientPriceCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 客户单价修改接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> UpdateClientPrice(UpdateClientPriceCommand request)
        {
            return await mediator.Send(request);    
        }
        /// <summary>
        /// 客户单价显示接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiPaging<ClientPriceDTO>> GetClientPrice([FromQuery]GetClientPriceCommand request)
        {
            return mediator.Send(request);
        }
    }
}
